package com.hellobike.haxing.modules.product.mapper;

import org.apache.ibatis.annotations.Param;
import com.hellobike.haxing.modules.product.entity.Category;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Description: 后台分类
 * @Author: haxing-boot
 * @Date:   2020-01-11
 * @Version: V1.0
 */
public interface CategoryMapper extends BaseMapper<Category> {

	/**
	 * 编辑节点状态
	 * @param id
	 * @param status
	 */
	void updateTreeNodeStatus(@Param("id") String id, @Param("status") String status);

	@Select("SELECT MAX(serial) FROM t_category WHERE parent_id=#{parentId}")//需包含已逻辑删除的，防止编码重复
	Integer getPeerMaxSerial(@Param("parentId") Long parentId);

	@Select("SELECT id, name, level, parent_id FROM t_category WHERE deleted=0")
	List<Category> getAll();
}
